package com.shiliao.app.activity.Feedback.presenter;

import android.text.TextUtils;

import com.shiliao.app.activity.Feedback.service.IFeedbackDetailService;
import com.shiliao.app.activity.Feedback.service.impl.FeedbackDetailImpl;
import com.shiliao.app.activity.Feedback.view.FeedbackDetailView;
import com.shiliao.app.utils.YMServerUtil;
import com.yimei.framework.mvp.presenter.IBasePresenter;
import com.yimei.framework.network.ICallBack;
import com.yimei.framework.util.LogUtil;

import java.util.HashMap;
import java.util.Map;


/**
 * Created by yinzhiqiang on 2017/9/8.
 */

public class FeedbackDetailPresenter extends IBasePresenter<IFeedbackDetailService> {

    private FeedbackDetailView feedbackDetailView;
    private IFeedbackDetailService feedbackDetailService;

    public FeedbackDetailPresenter(FeedbackDetailView feedbackDetailView) {
        this.feedbackDetailView = feedbackDetailView;
        feedbackDetailService = new FeedbackDetailImpl();
        setService(feedbackDetailService);
    }


    public void requestSuggstion(String userID, String suggestion) {
        super.loadData();
        Map map = new HashMap();
        if (!TextUtils.isEmpty(userID)) {
            map.put("user_id", userID);
        }
        if (!TextUtils.isEmpty(suggestion)) {
            map.put("suggestion", suggestion);
        }
        feedbackDetailService.request(YMServerUtil.ACTION_SUGGESTION, map, new ICallBack() {
            @Override
            public void onSuccess(int statusCode, Object result) {
                LogUtil.e("yzq", result.toString());
                feedbackDetailView.backFeedback();
            }

            @Override
            public void onFail(int statusCode, Object result) {

            }
        });
    }
}
